#include <iostream>
#include <pthread.h>
#include <string>
#include <vector>
#include <queue>
#include <unistd.h>
#include "Task.hpp"
#include "ThreadPool.hpp"
const std::string oper = "+-*/%";


int main()
{
    //循环启动线程，会重复创建线程，导致线程会不断增多
    // ThreadPool<task>* TP = new ThreadPool<task>;
    // TP->ThreadStart();
    // ThreadPool<task>* TP = ThreadPool<task>::SignaltionInstance();
    // SignaltionThreadPool<task>::_inst->ThreadStart();

    //饿汉模式
    auto TP = SignaletonThreadPool<task>::GetSignalInstance();
    TP->ThreadStart();

    while (true)
    {
        srand((unsigned)time(nullptr));

        char op = oper[rand() % oper.size()];
        int x = rand() % 100 + 1;
        int y = rand() % 100 + 1;
        // std::cout << x << ' ' << y << ' ' << oper << std::endl;
        task t(x, y, op);
        t();
        TP->push(t);

        sleep(1);
    }

    return 0;
}